﻿<%@ Page Language="C#" MasterPageFile="~/GestorEventos.Master" AutoEventWireup="true" CodeBehind="listEventos.aspx.cs" Inherits="GestorEventos.WebForm4" Title="Untitled Page" %>
<%@ Import Namespace="Business" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="UserArea" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Main" runat="server">

<table>
<%  
    ListaEvento business = new ListaEvento();
    ListaEvento listaEvento = new ListaEvento();

    Evento ev = new Evento();

    if (Request.QueryString["list"] != null)
    {
        int list = Convert.ToInt32(Request.QueryString["list"].ToString());
        if (list == 0 || list == 1 || list == 2 || list == 3 || list == 4)
        {
            listaEvento = new ListaEvento(business.getListaEvento(list));
        }

    }
    else
    {

        listaEvento = new ListaEvento(business.getListaEvento(-10));
    }





    System.Collections.Generic.List<Evento> listEvento = listaEvento.getListaEventos();

        int i=0;
    while(i<listEvento.Count+1)
    {
       
    %>
        <tr>
            <td>
                <asp:Label ID="LabelNome" runat="server"></asp:Label>
                <%if (i == listEvento.Count)
                      LabelNome.Text = listEvento[i - 1].getNome();
                  else
                      LabelNome.Text = listEvento[i].getNome(); %>
            </td>
            <td>
            <asp:HyperLink ID="HyperLink" runat="server"></asp:HyperLink>
            <%  HyperLink.Text = "Consultar";
                if(i==listEvento.Count)
                    HyperLink.NavigateUrl = "showEvento.aspx?eventID=" + listEvento[i-1].getID() + "";
                else
                    HyperLink.NavigateUrl = "showEvento.aspx?eventID=" + listEvento[i].getID() + ""; %>            
            </td>
            
            <td>
                <asp:Label ID="LabelStatus" runat="server"></asp:Label>
            <% 
                int st = 0;
                if (i == listEvento.Count)
                    st = i - 1;
                else
                    st = i;            
                switch (listEvento[st].getStatus())
                {
                    case 0: LabelStatus.Text = "Removido";
                        break;
                    case 1: LabelStatus.Text = "Por Aprovar";
                        break;
                    case 2: LabelStatus.Text = "Aprovado";
                        break;
                    case 3: LabelStatus.Text = "Em revisão";
                        break;
                }%>
            </td>
        </tr>        
    <% i++;
    }
    %>
    </table>
    <table>
    <tr>
            <td>
                <asp:Label ID="Label10" runat="server"></asp:Label>
                <% Label10.Text=i.ToString(); %>
            </td>
            
     </tr>        
     </table>

</asp:Content>
